-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
@tmpsantos, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @1ec5 and @incanus to be potential reviewers. |
fc8ce2b
to
da4e126
Compare
include/mbgl/map/map.hpp
Outdated
@@ -185,6 +185,10 @@ class Map : private util::noncopyable { | |||
std::vector<Feature> queryRenderedFeatures(const ScreenBox&, const optional<std::vector<std::string>>& layerIDs = {}); | |||
AnnotationIDs queryPointAnnotations(const ScreenBox&); | |||
|
|||
// Tile prefatching |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
include/mbgl/map/map.hpp
Outdated
@@ -185,6 +185,10 @@ class Map : private util::noncopyable { | |||
std::vector<Feature> queryRenderedFeatures(const ScreenBox&, const optional<std::vector<std::string>>& layerIDs = {}); | |||
AnnotationIDs queryPointAnnotations(const ScreenBox&); | |||
|
|||
// Tile prefatching | |||
void setFixedPrefetchZoom(uint32_t); | |||
void setDynamicPrefetchZoom(uint32_t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation
src/mbgl/style/source_impl.cpp
Outdated
|
||
// Request lower zoom level tiles (if configure to do so) in an attempt | ||
// to show something on the screen faster at the cost of a little of bandwidth. | ||
lowResolutionZoom = parameters.fixedPrefetchZoom ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks if fixedPrefetchZoom
is set to 0
, which is a valid use case.
src/mbgl/style/source_impl.cpp
Outdated
lowResolutionZoom = lowResolutionZoom < zoomRange.min ? zoomRange.min : lowResolutionZoom; | ||
|
||
if (lowResolutionZoom < idealZoom) { | ||
lowResolutionTiles = util::tileCover(parameters.transformState, lowResolutionZoom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In previous implementations (JS), we've called this "panZoom"
. Not sure if that's a better name though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with that. Let's use panZoom
for the sake of consistency.
src/mbgl/style/source_impl.cpp
Outdated
if (retain.find(tile.id) == retain.end()) { | ||
retain.emplace(tile.id); | ||
tile.setNecessity(necessity); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (retain.emplace(tile.id).second) {
tile.setNecessity(necessity);
}
.second
is true
when something was inserted, false
otherwise.
src/mbgl/style/source_impl.cpp
Outdated
// to show something on the screen faster at the cost of a little of bandwidth. | ||
lowResolutionZoom = parameters.fixedPrefetchZoom ? | ||
parameters.fixedPrefetchZoom : | ||
idealZoom - parameters.dynamicPrefetchZoom; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possible integer overflow here if idealZoom < parameters.dynamicPrefetchZoom
?
src/mbgl/style/source_impl.cpp
Outdated
parameters.fixedPrefetchZoom : | ||
idealZoom - parameters.dynamicPrefetchZoom; | ||
|
||
lowResolutionZoom = lowResolutionZoom < zoomRange.min ? zoomRange.min : lowResolutionZoom; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use std::min
to make this more readable?
src/mbgl/style/update_parameters.hpp
Outdated
@@ -42,6 +46,9 @@ class UpdateParameters { | |||
|
|||
// TODO: remove | |||
Style& style; | |||
|
|||
const uint32_t fixedPrefetchZoom; | |||
const uint32_t dynamicPrefetchZoom; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case for having both fixed and dynamic prefetch? Which one takes precedence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documented now. Fixed takes precedence.
src/mbgl/util/tile_cover.cpp
Outdated
int32_t coveringZoomLevel(double zoom, SourceType type, uint16_t size) { | ||
zoom += std::log(util::tileSize / size) / std::log(2); | ||
uint32_t coveringZoomLevel(double zoom, SourceType type, uint16_t size) { | ||
zoom = std::max(0., zoom) + std::log(util::tileSize / size) / std::log(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this max
call include the addition (which accounts for satellite tile size differences)? Otherwise, it could be impossible to use z0 for satellite tiles.
d6b1bfe
to
3cc2f15
Compare
3cc2f15
to
e033cf8
Compare
👀 @kkaefer |
e033cf8
to
a991620
Compare
ae6d2a2
to
dfd719a
Compare
Should I close this as deferred? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this out with a dynamicPrefetchZoomDelta
of 3, and it does exacerbate #7026.
Without prefetching, the flickering occurs only if you have tiles in the disk cache at a lower zoom level than the area you are panning over. With prefetching, the flickering always occurs.
So I think we should hold this feature until we fix #7026.
src/mbgl/map/map.cpp
Outdated
@@ -95,6 +95,9 @@ class Map::Impl : public style::Observer { | |||
|
|||
std::unique_ptr<AsyncRequest> styleRequest; | |||
|
|||
int32_t fixedPrefetchZoom = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To indicate the lack of a value, use optional
rather than negative integers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
438a29d
to
a49c473
Compare
@kkaefer is disabling partial tile rendering enough for landing this patch? I did a cheap test by simply tweaking
That said, nothing stops us for landing this today, since it is still very useful for a satellite map and would spare me from rebasing this branch and it is optional anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is disabling partial tile rendering enough for landing this patch?
No. Disabling partial rendering with the patch you suggested means that older/outdated buckets can't be used either. That means that rotating a map makes it appear blank until the buckets are reparsed.
a49c473
to
db83506
Compare
@kkaefer rebased and ready for reviewing again. This new version enables prefetching only for raster until we fix the label flickering. On this gif you see the difference (the tiles are offline cached on both scenarios, it is even more evident when you get tiles from the network). |
db83506
to
5d960d5
Compare
algorithm::updateRenderables(getTileFn, createTileFn, retainTileFn, | ||
[](const UnwrappedTileID&, Tile&) {}, panTiles, zoomRange, panZoom); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we merge this call to updateRenderables
into the other one by merging the panTiles
into idealTiles
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capturing from the chat: we have a separated algorithm::updateRenderables
because we don't create render tiles for pan tiles.
include/mbgl/map/map.hpp
Outdated
optional<uint8_t> getFixedPrefetchZoom() const; | ||
|
||
void setDynamicPrefetchZoomDelta(optional<uint8_t> delta); | ||
optional<uint8_t> getDynamicPrefetchZoomDelta() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the documentation, but I'm still not understanding why we need two different APIs for this. Can you please elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fixed is if you want to be cheap: you can set the prefetch zoom level to say, zoom level 5 and you will never have a blank spot on the map, but it will look very low res and overscaled. Soon you will get the whole world at zoom 5 in your cache.
The dynamic IMO is more interesting, but it will use more resources. You could set it to say, 2, and it will always prefetch "CurrentZoom - 2", it will pretty much make you never see blank spots with better looking overscaled tile but it will fill the cache faster and also use more bandwidth.
I find both approaches useful. We could drop the "dynamic" API and leave it to be implemented client side if you think we don't need 2 APIs.
bef817d
to
87ad0f4
Compare
Sort by z order, so lower res tiles don't get rendered over high res tiles.
87ad0f4
to
05f548c
Compare
Would you like to implement the SDK side of this change, or should we track that in separate tickets? |
I would like to track it in a separated ticket. |
The idea is to try to cover more map area and show the user something ASAP while the other tiles are still loading.
Exposes 2 new APIs:
Fixes #1626